package fenyu.personblob;

import com.google.gson.Gson;
import fenyu.personblob.bean.databean.User;
import fenyu.personblob.bean.strategy.Strategy;
import fenyu.personblob.single.SinglePathDoor;
import fenyu.personblob.web.model.UserShow;
import fenyu.personblob.web.util.TokenGetUserStrategy;
import fenyu.personblob.web.util.TokenMakerStrategy;

import java.util.HashMap;
import java.util.Map;

/**
 * create at 2018/12/21 14:19
 *
 * @author 纷羽 <gzj0078@gmail.com>
 */
public class Main {

    public static void main(String[] args) {
        System.out.println(new Gson().toJson(
                SinglePathDoor.getSingleSave().getSaveDoor().getUserSavePath().getAll()
        ));
        TokenMakerStrategy tokenMakerStrategy = new TokenMakerStrategy();
        User user = SinglePathDoor.getSingleSave().getSaveDoor().findByName("admin");
        Map<String, Object> data = new HashMap<>();
        String token = (String) tokenMakerStrategy.todo(user);
        data.put("code", "1");
        data.put("message", "ok");
        data.put("token", token);
        System.out.println(new Gson().toJson(data));
        Strategy tokenGetUserStrategy = new TokenGetUserStrategy();
        System.out.println(new UserShow((User) tokenGetUserStrategy.todo(token)));
    }
}
